package com.example.androidlearning.sy10.sy2sqlite;

import android.content.Context;
import android.database.sqlite.SQLiteDatabase;
import android.database.sqlite.SQLiteOpenHelper;

public class MyDatabaseHelper extends SQLiteOpenHelper {
    private final String CREATE_TABLE_SQL = "create table user_info(_account string primary key, password , name, email, tel, work)";
    private final String CREATE_DICT_TABLE = "create table dict(_id integer primary key autoincrement not null, word, detail)";

    public MyDatabaseHelper(Context context, String name, int version) {
        super(context, name, null, version);
    }

    @Override
    public void onCreate(SQLiteDatabase db) {
        // 第一次使用数据库时自动建表
        db.execSQL(CREATE_TABLE_SQL);
        db.execSQL(CREATE_DICT_TABLE);
    }

    @Override
    public void onUpgrade(SQLiteDatabase db
            , int oldVersion, int newVersion) {

//        db.execSQL(CREATE_TABLE_SQL);
//        db.execSQL(CREATE_DICT_TABLE);

        System.out.println("--------onUpdate Called--------"
                + oldVersion + "--->" + newVersion);
    }
}

